package com.servlet;

import com.dao.BooksUtilsDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/CartServlet")
public class CartServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        BooksUtilsDao dao = new BooksUtilsDao();
        try {           
            double sumnumber = dao.sumnumber();           
            double sumprice = dao.sumprice();            
            request.getSession().setAttribute("sumnumber", sumnumber);
            request.getSession().setAttribute("sumprice", sumprice);
        } catch (Exception e) {
            e.printStackTrace();
        }
        request.getRequestDispatcher("cart.jsp").forward(request, response);
    }



    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
